<template>
	<div>
		<vxe-modal v-model="dialogVisible" title="请填写驾驶员相关信息" width="900" height="530" show-zoom resize remember>
			<template #default>
				<vxe-form title-colon ref="xForm" title-align="right" title-width="130" :data="formData2"
					:rules="formRules2" :loading="loading2" @submit="submitEvent2" @reset="resetEvent">
					<vxe-form-gather span="24">
						<vxe-form-item title="驾驶员编号" field="t1" span="24" :item-render="{}" title-overflow="title">
							<template #default="params">
								<vxe-input v-model="params.data.t1" placeholder="请输入驾驶员编号" clearable
									@input="$refs.xForm.updateStatus(params)"></vxe-input>
							</template>
						</vxe-form-item>
						<vxe-form-item title="驾驶员姓名" field="t2" span="24" :item-render="{}" title-overflow="title">
							<template #default="params">
								<vxe-input v-model="params.data.t2" placeholder="请输入驾驶员姓名" clearable
									@input="$refs.xForm.updateStatus(params)"></vxe-input>
							</template>
						</vxe-form-item>
						<vxe-form-item title="性别" field="t3" span="24" :item-render="{}" title-overflow="title">
							<template #default="params">
								<vxe-input v-model="params.data.t3" placeholder="请输入性别" clearable
									@input="$refs.xForm.updateStatus(params)"></vxe-input>
							</template>
						</vxe-form-item>
						<vxe-form-item title="年龄" field="t4" span="24" :item-render="{}" title-overflow="title">
							<template #default="params">
								<vxe-input v-model="params.data.t4" placeholder="请输入年龄" clearable
									@input="$refs.xForm.updateStatus(params)"></vxe-input>
							</template>
						</vxe-form-item>
						<vxe-form-item title="默认车辆车牌号" field="t5" span="24" :item-render="{}"
							title-overflow="title">
							<template #default="params">
								<vxe-input v-model="params.data.t5" placeholder="请输入默认车辆车牌号" clearable
									@input="$refs.xForm.updateStatus(params)"></vxe-input>
							</template>
						</vxe-form-item>
						<vxe-form-item title="驾驶证号" field="t6" span="24" :item-render="{}" title-overflow="title">
							<template #default="params">
								<vxe-input v-model="params.data.t6" placeholder="请输入驾驶证号" clearable
									@input="$refs.xForm.updateStatus(params)"></vxe-input>
							</template>
						</vxe-form-item>
						<vxe-form-item title="联系方式" field="t7" span="24" :item-render="{}" title-overflow="title">
							<template #default="params">
								<vxe-input v-model="params.data.t7" placeholder="请输入联系方式" clearable
									@input="$refs.xForm.updateStatus(params)"></vxe-input>
							</template>
						</vxe-form-item>
						


					</vxe-form-gather>
					
					<vxe-form-item align="center" span="24" :item-render="{}">
						<template #default>
							<vxe-button type="submit" status="primary">提交</vxe-button>
							<vxe-button type="reset">重置</vxe-button>
						</template>
					</vxe-form-item>
				</vxe-form>
			</template>
		</vxe-modal>
	</div>
</template>

<script>
	import {
		sava,
		edit,
		getcompany,
		getDepList,
		btypelist
	} from './index.js';
	import {
		list
	} from './index.js';
	import {
		checkNumber
	} from '@/shop/util/validator.js'

	export default {
		data() {
			return {
				dialogImageUrl: '',
				dialogVisibleimg: false,
				disabled: false,
				formData2: {
					"batModelId": '',
					"batNo": "",
					"batTypeId": 1,
					"companyId": 0,
					"operationDepartment": 1,
					"pd": "",
					"sd": "",
				},
				showment: true,
				companyact: '',
				depment: '',
				companylist: [],
				departmentlist: [],
				userinfo: {},
				loading2: false,
				formRules2: {
					batModelId: [{
						required: true,
						message: '请输入生产单位段名称',
						trigger: 'blur'
					}],
					batNo: [{
						required: true,
						message: '请输入出生天数起始',
						trigger: 'blur'
					}],
					companyId: [{
						required: true,
						message: '请选择公司'
					}],
					operationDepartment: [{
						required: true,
						message: '请输入部门'
					}],
					pd: [{
						required: true,
						message: '请选择生产日期'
					}],
					sd: [{
						required: true,
						message: '请选择销售日期'
					}]
				},
				dialogVisible: false,
				loading: false,
				typeList: [{
						label: '三元锂',
						value: '1'
					},
					{
						label: '二氧化硅',
						value: '2'
					}
				],
				modelList: []

			};
		},
		created() {
			// this.btypelist();
			// this.getmodel();

		},
		methods: {
			handleRemove(file) {
				console.log(file);
			},
			handlePictureCardPreview(file) {
				this.dialogImageUrl = file.url;
				this.dialogVisibleimg = true;
			},
			handleDownload(file) {
				console.log(file);
			},
			handleClose(done) {
				this.resetForm('ruleForm');
				done();
			},
			slel(e) {
				this.showment = false;
				let that = this;
				that.showment = true;
			},
			open(item) {
				console.log(item)
				this.formData2 = {
					...item
				};
				let userinfo = JSON.parse(localStorage.getItem("userinfo"));
				this.userinfo = userinfo;
				// if (userinfo.companyid != 1) {
				// 	this.formData2.companyId = userinfo.companyid;

				// }
				// this.getcompany();
				// this.getDepList();
				this.dialogVisible = true;
			},
			compancheg(e) {
				this.formData2.operationDepartment = '';
				this.companylist.forEach(item => {
					if (item.id == this.formData2.companyId) {
						this.formData2.company = item
					}
				})

				this.getDepList();
			},
			
			submitEvent2(e) {
				console.log(e);
				this.loading2 = true
				setTimeout(() => {
					this.loading2 = false
					this.oldsava();
				}, 1000)
			},
			searchEvent() {
				this.msgSuccess('查询事件')
			},
			resetEvent() {
				this.msgSuccess('重置')
			},
			
			async oldsava() {
				this.loading = true;
				this.msgSuccess("修改成功");
				this.resetForm('formData2');
				this.dialogVisible = false;
				this.$emit('oldlist')
				// this.ruleForm.token = localStorage.getItem('goods__token')
				// this.ruleForm.oldname = this.ruleForm.oname;
				// let result;
				// if (this.formData2.id) {
				// 	result = await edit(this.formData2);
				// } else {
				// 	result = await sava(this.formData2);
				// }
				// this.loading = false;
				// if (result.code == 1) {
				// 	if (this.formData2.id === undefined) {
				// 		this.msgSuccess("新增成功");
				// 	} else {
				// 		this.msgSuccess("修改成功");
				// 	}

				// 	this.resetForm('formData2');
				// 	this.dialogVisible = false;
				// 	this.$emit('oldlist')
				// }

			}
		}
	};
</script>

<style></style>
